#!/bin/sh
PATH_REPORT="$HOME/.cache/checkbox/submission.xml"
ID_FILE_PATH = "/usr/dooplet/laptop_id.txt"
LABDOO_SERVER_REPORT=""
ID_LAPTOP = `cat /usr/dooplet/laptop_id.txt | head -n 1`
CPU_PERCENT=`top -b -n 1 | head -n 3 | tail -n 1  | tr -s " " | cut -d' ' -f2 | cut -d% -f1` >> "/tmp/cpus.log"
if ! [ -e "/tmp/cpus.log" ]; then
	touch "/tmp/cpus.log"
fi

for value in `cat '/tmp/cpus.log' | tail -n5 | tac`; do
	NUMBER_ENTER=`echo $value | cut -d'.' -f1`
	echo "number to compare : $NUMBER_ENTER"
	if [ "$NUMBER_ENTER" -gt 30  ];  then
		at -f ./getcpu.sh now + 1 minutes
		exit
	fi
done 
#echo "executing checkbox...."
rm -f "/tmp/cpus.log"
echo "calling checkbox-doop"
checkbox-doop
echo "sending information to the labdoo server"
scp -i labdoo-dev.pem "$PATH_REPORT"  "root@$LABDOO_SERVER_REPORT:/persistent/problems/$ID_LAPTOP"




